//
//  CZUser.m
//  XinLang_OC
//
//  Created by WONG on 16/3/10.
//  Copyright © 2016年 cheuhui. All rights reserved.
//

#import "CZUser.h"

@implementation CZUser

/**
 *  字典转模型
 */
- (instancetype)initWithDict:(NSDictionary *)dict {
    if (self = [super init]) {
        [self setValuesForKeysWithDictionary:dict];
    }
    return self;
}
+ (instancetype)userWithDict:(NSDictionary *)dict {
    return [[self alloc] initWithDict:dict];
}
// 字典的key在模型中找不到对应的属性 调用
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {}

// verified_type 没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
- (void)setVerified_type:(int)verified_type {
    _verified_type = verified_type;
    
    if (_verified_type == 0) {
        self.verifiedImage = [UIImage imageNamed:@"avatar_vip"];
    }else if (_verified_type == 2 || _verified_type == 3 || _verified_type == 5) {
        self.verifiedImage = [UIImage imageNamed:@"avatar_enterprise_vip"];
    }else if (_verified_type == 220) {
        self.verifiedImage = [UIImage imageNamed:@"avatar_grassroot"];
    }else {
        self.verifiedImage = nil;
    }
}
// 会员等级 1-6
- (void)setMbrank:(int)mbrank {
    _mbrank = mbrank;
    
    if (_mbrank > 0 && mbrank < 7) {
        NSString *imgStr = [NSString stringWithFormat:@"common_icon_membership_level%d",_mbrank];
        self.mbrankImage = [UIImage imageNamed:imgStr];
    }else {
        self.mbrankImage = nil;
    }
}


/**
 *  打印对象信息调用
 */
- (NSString *)description {
    NSArray *properties = @[@"id", @"screen_name", @"profile_image_url", @"verified", @"verified_type", @"mbrank"];
    NSDictionary *dict = [self dictionaryWithValuesForKeys:properties];
    return [NSString stringWithFormat:@"%@",dict];
}


#pragma mark - lazy load



@end














